/**
 * The PacketAction enum
 *
 * @author  Jill San Luis
 */
public enum PacketAction {

    JOIN(1){
        public void act(Client c){
            // TODO: figure out if it is right
            // for now do nothing
        }
    },
    LEFT(2){
        public void act(Client c){
            c.turnLeft();
        }
    },
    RIGHT(3){
        public void act(Client c){
            c.turnRight();
        }
    },
    UP(4){
        public void act(Client c){
            c.forward();
        }
    },
    DOWN(5){
        public void act(Client c){
            c.backup();
        }
    },
    FIRE(6){
        public void act(Client c){
            c.fire();
        }
    },
    QUIT(7){
        public void act(Client c){
            // TODO: figure out if it is right
            // for now do nothing
        }
    };

    public static PacketAction getPacketAction(int action) {

        for (PacketAction pa : PacketAction.values()) {
            if (pa.getAction() == action) {
                return pa;
            }
        }

        return null;
    }
    private int action;

    /**
     * Creates a new instance of PacketAction.
     */
    private PacketAction(int action) {
        this.action = action;
    }

    public int getAction() {
        return action;
    }

    public abstract void act(Client client);
}
